****************************************************************************************************
*Replication for "Leaders, Advisers, and the Political Origins of Elite Support for War"
*Journal of Conflict Resolution
*Elizabeth N. Saunders
*This version: July 2018 (v1)
*Please be sure to check Harvard Dataverse for latest version:  https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/BDYQC2 
*Please contact the author if you encounter any problems with this replication file
****************************************************************************************************


*This do-file does the following:
*1.  Generates variables for analysis
*2.  Provides code for analysis reported in paper, including tables and figures


use LeadersAdvisersJCRReplication.dta

******************************************************
*Variables (all variables already created in dataset)*
******************************************************


*DEPENDENT VARIABLES*

*War Support (Stage 1)
*If the attacker cannot be talked into withdrawing, would you support or oppose sending U.S. troops to push back the invaders?
*	Support (1)
*	Oppose (2)
*	Neither support nor oppose (3)
*
*
*Do you feel strongly about this, or not very strongly?
*	Strongly (1)
*	Not very strongly (2)
*
*
* Do you lean toward supporting a troop deployment, leaning toward opposing, or don't you lean either way?
*	I lean toward supporting a troop deployment (1)
*	I lean toward opposing a troop deployment (2)
*	I don't lean either way (3)


gen warsupport7=1 if warsupport==1 & warstrength==1
replace warsupport7=2 if warsupport==1 & warstrength==2 
replace warsupport7=3 if warlean==1 
replace warsupport7=4 if warlean==3
replace warsupport7=5 if warlean==2
replace warsupport7=6 if warsupport==2 & warstrength==2
replace warsupport7=7 if warsupport==2 & warstrength==1
label define warsupport7 1 "Strongly Support" 2 "Somewhat Support" 3 "Lean Support" 4 "No Lean" 5 "Lean Oppose" 6 "Somewhat Oppose" 7 "Strongly Oppose" 
label values warsupport7 warsupport7

***Putting leaners into support/oppose"
gen warsupport3=1 if warsupport==1 | warlean==1
replace warsupport3=3 if warsupport==2 | warlean==2 
replace warsupport3=2 if warlean==3
label define warsupport3 1 "Support" 2 "Neither support/oppose" 3 "Oppose"
label values warsupport3 warsupport3

tab warsupport3, gen(suppdummy)
rename suppdummy1 suppd
label define suppd 1 "Support" 0 "Neither or Oppose"
label values suppd suppd


*Approval after decision (Stage 2)

*Do you approve or disapprove of the way the U.S. president handled this situation?
*	Approve (1)
*	Disapprove (2)
*	Neither approve nor disapprove (3)
*
*Do you strongly approve or only somewhat?
*	I strongly approve of the way the president handled the situation (1)
*	I only somewhat approve of the way the president handled the situation (2)
*Do you strongly disapprove or only somewhat?
*	I strongly disapprove of the way the president handled the situation (1)
*	I only somewhat disapprove of the way the president handled the situation (2)

*Do you lean toward approving of the way the U.S. president handled the situation, lean toward disapproving, or don’t you lean either way?
*	I lean toward approving of the way the president handled the situation (1)
*	I lean toward disapproving of the way the president handled the situation (2)
*	I don’t lean either way (3)


gen approve7=1 if approvestrength==1 
replace approve7=2 if approvestrength==2 
replace approve7=3 if approvelean==1 
replace approve7=4 if approvelean==3
replace approve7=5 if approvelean==2
replace approve7=6 if disapprovestrength==2
replace approve7=7 if disapprovestrength==1
label define approve7 1 "Strongly Approve" 2 "Somewhat Approve" 3 "Lean Approve" 4 "No Lean" 5 "Lean Disapprove" 6 "Somewhat Disapprove" 7 "Strongly Disapprove" 
label values approve7 approve7

***Putting leaners and somewhats into approve/disapprove"
gen approve3=1 if approve7==1 | approve7==2 | approve7==3
replace approve3=3 if approve7==5 | approve7==6 | approve7==7
replace approve3=2 if approve7==4
label define approve3 1 "Approve" 2 "Neither Approve/Disapprove" 3 "Disapprove"
label values approve3 approve3

tab approve3, gen(appdummy)
rename appdummy1 appd
label define appd 1 "Approve" 0 "Neither or Disapprove"
label values appd appd




*Experimental Variables

********************
*Treatment: "criticism"
*1	No adviser speech
*2	Hawk supports force
*3	Dove opposes force
*4	Hawk opposes force
*5	Dove supports force
**********************

destring randCriticism, gen(adviserspeech)
label define adviserspeech 1 "No adviser speech" 2 "Hawk supports force" 3 "Dove opposes force" 4 "Hawk opposes force" 5 "Dove supports force"
label values adviserspeech adviserspeech

*Adviser Statement: Reordering for hawk/dove support/oppose clarity (this variable used in analysis below)

*adviserstate:
*          1 No adviser speech
*           2 Hawk supports force
*           3 Hawk opposes force
*           4 Dove supports force
*           5 Dove opposes force

gen adviserstate=adviserspeech
recode adviserstate 4=3 5=4 3=5
label define adviserstate 1 "No adviser speech" 2 "Hawk supports force" 3 "Hawk opposes force" 4 "Dove supports force" 5 "Dove opposes force"
label values adviserstate adviserstate


*Adviser Support (for or against force)*
gen advisersupport=adviserspeech
recode advisersupport 5=2 4=3
label define advisersupport 1 "No adviser speech" 2 "Adviser supports force" 3 "Adviser opposes force"
label values advisersupport advisersupport

*Match with Adviser's Recommendation*

gen advisermatch=.
replace advisermatch=1 if advisersupport==1
replace advisermatch=2 if (advisersupport==2 & troops==1) | (advisersupport==3 & troops==0)
replace advisermatch=3 if (advisersupport==2 & troops==0) | (advisersupport==3 & troops==1)
label define advisermatch 1 "No adviser speech" 2 "Acted as adviser recommended" 3 "Acted against adviser rec"
label values advisermatch advisermatch

*Adviser speech true or against type*
gen advisertype=.
replace advisertype=1 if adviserspeech==1
replace advisertype=2 if adviserspeech==2  | adviserspeech==3
replace advisertype=3 if adviserspeech==4  | adviserspeech==5 
label define advisertype 1 "No adviser speech" 2 "Adviser true type" 3 "Adviser against type"
label values advisertype advisertype

*Hawk/Dove dummy*
gen hawkdove=adviserspeech
recode hawkdove 1=. 3=0 5=0 2=1 4=1
label define hawkdove 0 "Dovish adviser" 1 "Hawkish adviser"
label values hawkdove hawkdove

*Support/Oppose dummy*
gen supportoppose=adviserspeech
recode supportoppose 1=. 2=1 3=0 4=0 5=1
label define supportoppose 1 "Adviser supports force" 0 "Adviser opposes force"
label values supportoppose supportoppose

*Oppose/Support dummy*
gen opposesupport=adviserspeech
recode opposesupport 1=. 2=0 3=1 4=1 5=0
label define opposesupport 1 "Adviser opposes force" 0 "Adviser supports force"
label values opposesupport opposesupport

*President's Party*
destring randParty, gen(presparty)
recode presparty 1=0 2=1
label define presparty 0 "Democrat" 1 "Republican"
label values presparty presparty

*Troop decision*
destring randIntervene, gen(troops)
recode troops 2=0
label define troops 0 "No Troops" 1 "Sent Troops"
label values troops troops


*********************************
*Table 1a, Stage 1 (War Support)*
*********************************

***************************************
*advisersupport:
*           1 No adviser speech
*           2 Adviser supports force
*           3 Adviser opposes force
*
***************************************
quietly logit suppd i.supportoppose
margins r.supportoppose

prtest suppd if advisersupport~=1, by(advisersupport)
prtest suppd if advisersupport~=2, by(advisersupport)
prtest suppd if advisersupport~=3, by(advisersupport)

*********************************************
*Table 1a, Stage 2 (Approval after decision)*
*********************************************


*If adviser supported or opposed troops, and by presidential decision to send troops or stay out
prtest appd if advisersupport==1, by(troops)
prtest appd if advisersupport==2, by(troops)
prtest appd if advisersupport==3, by(troops)

*Comparing action relative to support/opposition

prtest appd if advisersupport~=1 & troops==0, by(advisersupport)
prtest appd if advisersupport~=1 & troops==1, by(advisersupport)
prtest appd if advisersupport~=2 & troops==0, by(advisersupport)
prtest appd if advisersupport~=2 & troops==1, by(advisersupport)
prtest appd if advisersupport~=3 & troops==0, by(advisersupport)
prtest appd if advisersupport~=3 & troops==1, by(advisersupport)

quietly logit appd i.advisersupport##i.troops
margins r.troops, over(advisersupport) contrast post 

*Difference-in-difference for adviser support vs. oppose, by troop decision

************************************
*supportoppose:
*           0 Adviser opposes force
*          1 Adviser supports force
************************************

quietly logit appd i.supportoppose##i.troops
margins r.troops, over(r.supportoppose) contrast post

***************************************************************
*Table 1b, Effect of Action after Adviser Statements (Stage 2)*
***************************************************************

***************************************************************
*advisermatch:
*           1 No adviser speech
*           2 Acted as adviser recommended (sent troops if adviser recommended troops, or stayed out if adviser recommended staying out)
*           3 Acted against adviser rec (sent troops if adviser recommended staying out, or stayed out if adviser recommended sending troops)
***************************************************************

prtest appd if advisermatch~=1, by(advisermatch)
prtest appd if advisermatch~=2, by(advisermatch)
prtest appd if advisermatch~=3, by(advisermatch)

quietly logit appd i.advisermatch
margins r.advisermatch

*************************************************
*Table 2: Support for War (by President's Party)*
*************************************************

*Democratic President (presparty==0)

quietly logit suppd i.adviserstate if presparty==0
margins adviserstate if presparty==0

*Differences from baseline (adviserstate==1)

quietly logit suppd i.adviserstate if presparty==0
margins r.adviserstate if presparty==0

**Hawk/Dove Speech Comparisons (Support vs. Oppose)

quietly logit suppd i.hawkdove##i.supportoppose if presparty==0
margins r.supportoppose, over(hawkdove) contrast post

*Diff-in-Diff (Hawk swing vs. Dove Swing)
quietly logit suppd i.hawkdove##i.supportoppose if presparty==0
margins r.supportoppose, over(r.hawkdove) contrast



*Republican President (presparty==1)

quietly logit suppd i.adviserstate if presparty==1
margins adviserstate if presparty==1

*Differences from baseline (adviserstate==1)**

quietly logit suppd i.adviserstate if presparty==1
margins r.adviserstate if presparty==1

*Hawk/Dove Speech Comparisons (Support vs. Oppose)

quietly logit suppd i.hawkdove##i.supportoppose if presparty==1
margins r.supportoppose, over(hawkdove) contrast post

*Diff-in-Diff (Hawk swing vs. Dove Swing)
quietly logit suppd i.hawkdove##i.supportoppose if presparty==1
margins r.supportoppose, over(r.hawkdove) contrast

*Partisan differences**

prtest suppd if adviserstate==1, by(presparty)
prtest suppd if adviserstate==2, by(presparty)
prtest suppd if adviserstate==3, by(presparty)
prtest suppd if adviserstate==4, by(presparty)
prtest suppd if adviserstate==5, by(presparty)

quietly logit suppd i.adviserstate##i.presparty
margins r.presparty, over(adviserstate)
margins r.presparty, over(r.adviserstate)
quietly logit suppd i.hawkdove##i.supportoppose##i.presparty
margins r.supportoppose, over(r.presparty) at(hawkdove==0) at(hawkdove==1) contrast

*Diff-in-diff (Hawk swing vs. Dove swing by partisan difference)
quietly logit suppd i.hawkdove##i.supportoppose##i.presparty
margins r.supportoppose, over(r.presparty) at(hawkdove==0) at(hawkdove==1) contrast(atcontrast(r._at))



*************************************
*Figure 3: Support for War (Stage 1)*
*************************************

		  
*Label used for figures*		   
label define adviserst2 1 "No adviser speech" 2 "Supports force" 3 "Opposes force" 4 "Supports force" 5 "Opposes force"
quietly logit suppd i.adviserstate##i.presparty
estimates store raw
margins adviserstate, at(presparty==0) post
estimates store SuppDem
estimates restore raw
margins adviserstate, at(presparty==1) post 
estimates store SuppRep


label values adviserstate adviserst2
coefplot (SuppDem), bylabel({bf:Democratic President}) mlcolor(midblue) mfcolor(midblue) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue)) || (SuppRep), bylabel({bf:Republican President}) mlcolor(red) mfcolor(white) msymbol(O) msize(medium) mlabcolor(red) ciopts(lcolor(red)) ||, graphregion(color(white)) norecycle mlabel format(%9.2g) mlabposition(12) headings(1.adviserstate = "{bf:Control}" 2.adviserstate = "{bf:Hawkish adviser}" 4.adviserstate = "{bf:Dovish adviser}") grid(n) 
label values adviserstate adviserstate


***************************************************
*Table 3: Approval (Stage 2), Democratic President*
***************************************************

quietly logit appd i.adviserstate##i.troops if presparty==0
margins i.adviserstate##i.troops
margins r.adviserstate, over(troops) contrast
margins r.adviserstate, over(r.troops) contrast

quietly logit appd i.hawkdove##i.supportoppose##i.troops if presparty==0
margins r.supportoppose, over(hawkdove) at(troops==0) at(troops==1) contrast
margins r.troops, over(r.supportoppose) at(hawkdove=0) at(hawkdove==1) contrast 
margins r.supportoppose, over(r.hawkdove) at(troops==0) contrast
margins r.supportoppose, over(r.hawkdove) at(troops==1) contrast

*Diff in Diff (hawk swing vs. dove swing*
margins r.troops, over(r.supportoppose) at(hawkdove==0) at(hawkdove==1) contrast(atcontrast(r._at))



***************************************************
*Table 4: Approval (Stage 2), Republican President*
***************************************************

quietly logit appd i.adviserstate##i.troops if presparty==1
margins i.adviserstate##i.troops
margins r.adviserstate, over(troops) contrast
margins r.adviserstate, over(r.troops) contrast

quietly logit appd i.hawkdove##i.supportoppose##i.troops if presparty==1
margins r.supportoppose, over(hawkdove) at(troops==0) at(troops==1) contrast
margins r.troops, over(r.supportoppose) at(hawkdove=0) at(hawkdove==1) contrast 
margins r.supportoppose, over(r.hawkdove) at(troops==0) contrast
margins r.supportoppose, over(r.hawkdove) at(troops==1) contrast

*Diff in Diff (hawk swing vs. dove swing*
margins r.troops, over(r.supportoppose) at(hawkdove==0) at(hawkdove==1) contrast(atcontrast(r._at))



***********************************************************************
*Figure 4: Approval (Stage 2), by President's Party and Troop Decision*
***********************************************************************

		  
*Label used for figures*		   
label define adviserst2 1 "No adviser speech" 2 "Supports force" 3 "Opposes force" 4 "Supports force" 5 "Opposes force"

*Democrats*

quietly logit appd i.adviserstate##i.troops if presparty==0
estimates store raw
margins adviserstate, at(troops==0) post
estimates store NTD
estimates restore raw
margins adviserstate, at(troops==1) post
estimates store TD
coefplot (NTD, label(No Troops) mlcolor(midblue) mfcolor(white) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue))) (TD, label(Troops) mlcolor(midblue) mfcolor(midblue) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue))), graphregion(color(white)) mlabel format(%9.2g) mlabposition(12) headings(1.adviserstate = "{bf:Control}" 2.adviserstate = "{bf:Hawkish adviser}" 4.adviserstate = "{bf:Dovish adviser}")
graph save DemAppS2, replace

*Republicans*
quietly logit appd i.adviserstate##i.troops if presparty==1
estimates store raw
margins adviserstate, at(troops==0) post
estimates store NTR
estimates restore raw
margins adviserstate, at(troops==1) post
estimates store TR
coefplot (NTR, label(No Troops) mlcolor(red) mfcolor(white) msym(T) msize(medium) mlabcolor(red) ciopts(lcolor(red))) (TR, label(Troops) mlcolor(red) mfcolor(red) msym(T) msize(medium) mlabcolor(red) ciopts(lcolor(red))), graphregion(color(white)) mlabel format(%9.2g) mlabposition(12) headings(1.adviserstate = "{bf:Control}" 2.adviserstate = "{bf:Hawkish adviser}" 4.adviserstate = "{bf:Dovish adviser}")
graph save RepAppS2, replace


label values adviserstate adviserst2
coefplot (NTD, label(No Troops) mlcolor(midblue) mfcolor(white) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue))) (TD, label(Troops) mlcolor(midblue) mfcolor(midblue) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue))), bylabel({bf:Democratic President}) || (NTR, label(No Troops) mlcolor(red) mfcolor(white) msym(T) msize(medium) mlabcolor(red) ciopts(lcolor(red))) (TR, label(Troops) mlcolor(red) mfcolor(red) msym(T) msize(medium) mlabcolor(red) ciopts(lcolor(red))), bylabel({bf:Republican President}) graphregion(color(white)) mlabel format(%9.2g) mlabposition(12) norecycle headings(1.adviserstate = "{bf:Control}" 2.adviserstate = "{bf:Hawkish adviser}" 4.adviserstate = "{bf:Dovish adviser}")
label values adviserstate adviserstate



*********************
*FIG 5: Diff-in-Diff*
*********************

		  
*Label used for figures*		   
label define adviserst2 1 "No adviser speech" 2 "Supports force" 3 "Opposes force" 4 "Supports force" 5 "Opposes force"

*Democrats*
quietly logit appd i.hawkdove##i.opposesupport##i.troops if presparty==0
estimates store raw
margins r.troops, over(opposesupport) at(hawkdove=1) at(hawkdove==0) contrast post
estimates store DemTroopSwings
*Republicans**
quietly logit appd i.hawkdove##i.opposesupport##i.troops if presparty==1
estimates store raw
margins r.troops, over(opposesupport) at(hawkdove=1) at(hawkdove==0) contrast post
estimates store RepTroopSwings
coefplot (DemTroopSwings), bylabel({bf:Democratic President}) mlcolor(midblue) mfcolor(midblue) msym(O) msize(medium) mlabcolor(midblue) ciopts(lcolor(midblue)) || (RepTroopSwings), bylabel({bf:Republican President}) mlcolor(red) mfcolor(white) msymbol(O) msize(medium) mlabcolor(red) ciopts(lcolor(red)) || , coeflabel(r1vs0.troops@1._at#0.opposesupport = "Supports Force" r1vs0.troops@1._at#1.opposesupport = "Opposes Force" r1vs0.troops@2._at#0.opposesupport = "Supports Force" r1vs0.troops@2._at#1.opposesupport = "Opposes Force") norecycle graphregion(color(white)) mlabel format(%9.2f) mlabposition(12) headings(r1vs0.troops@1._at#0.opposesupport = "{bf:Hawkish adviser}" r1vs0.troops@2._at#0.opposesupport = "{bf:Dovish adviser}") grid(n)



*Misc

*Full sample gap in support for war by president's party
prtest suppd, by(presparty)

*To test on 3-point scale versions of DVs, replace code above with warsupport3/approve3, ologit, ttest
